clear

*This do file cleans merges with existing data files and analyzes diffusion
*Note: for all datasets, complete stateid do file prior to merge
*Last updated: May 12, 2022

*Insert your root folder location below
cd  "FOLDER YOUR LOCATION HERE

use "EVRR_Dataset.dta"


********************Generate Enfranchisement Years*****************************


*Creating DVAdoptYr and DVImpYear 
sort stateid year
by stateid: gen DVAdoptYr = 0
by stateid: replace DVAdoptYr = 1 if evrr_dejure==1 & evrr_dejure[_n-1]==0
by stateid: replace DVAdoptYr = 1 if evrr_dejure==1 & evrr_dejure[_n-1]==.e
by stateid: replace DVAdoptYr = 1 if evrr_dejure==1 & evrr_dejure[_n-1]==.a
list stateid country year if DVAdoptYr==1

*Check to identify reversals
list stateid country year if evrr_dejure==0 & evrr_dejure[_n-1]==1 & stateid==stateid[_n-1]

*Reversals include: Angola, Armenia, Cambodia, Fiji, Guyana
*Morocco, Marshall Islands, Panama, South Africa, San Marino, Turkmenistan

*Of these, Angola, Armenia, Cambodia, Guyana, San Marino reversed once
*For these, no additional tweaks are required

*For Fiji, Morocco, Marshall Islands, Panama, South Africa, and Turkmenistan
*Main variable uses first adoption

replace DVAdoptYr = 0 if stateid=="MOR" & year==2011
replace DVAdoptYr = 0 if stateid=="SAF" & year==2009
replace DVAdoptYr = 0 if stateid=="TKM" & year==1992
replace DVAdoptYr = 0 if stateid=="FJI" & year==2013
replace DVAdoptYr = 0 if stateid=="MSI" & year==2019
replace DVAdoptYr = 0 if stateid=="PAN" & year==2006


*First Year Implement*
sort stateid year
by stateid: gen DVImpYr = 0
by stateid: replace DVImpYr = 1 if evrr_defacto==1 & evrr_defacto[_n-1]==0
by stateid: replace DVImpYr = 1 if evrr_defacto==1 & evrr_defacto[_n-1]==.e
by stateid: replace DVImpYr = 1 if evrr_defacto==1 & evrr_defacto[_n-1]==.a
list stateid country year if DVImpYr==1

*Check to identify reversals
list stateid country year if evrr_defacto==0 & evrr_defacto[_n-1]==1 & stateid==stateid[_n-1]
*Reversals include: Afghanistan, Armenia, Benin, Burundi [2x], Cambodia, 
*Equatorial Guinea, Guinea-Bissau, Guyana, Morocco, Marshall Islands, Niger
*South Africa, San Marino

*For those with two DVImp=1 years, we'll code from the first

replace DVImpYr = 0 if stateid=="BEN" & year==2011
replace DVImpYr = 0 if stateid=="BUI" & year==2010
*replace DVImpYr = 0 if stateid=="CHA" & year==2011
replace DVImpYr = 0 if stateid=="EQG" & year==2019
replace DVImpYr = 0 if stateid=="GNB" & year==2013
replace DVImpYr = 0 if stateid=="MOR" & year==2011
replace DVImpYr = 0 if stateid=="SAF" & year==2009
replace DVImpYr = 0 if stateid=="STP" & year==2016

sort stateid year


***************Merge Treisman (colonial + legal legacies)********************
*Cutnote: remove folder root in final version
merge m:m stateid using "ExtraDatasets/colonial.dta"
list country year if _m==1
*Kosovo, Monaco, Montenegro, Nauru, Tuvalu not covered in Treisman
list country year if _m==2
*All small islands/territories EVRR does not include*
drop if _m==2
drop _m
list stateid country if britcol==. & year==2020
list stateid country if frencol==. & year==2020
list stateid country if spanporc==. & year==2020

*Countries missing for odd reasons 
*We fill it in with data from T&U
replace britcol = 1 if stateid=="AFG"
replace britcol = 0 if stateid=="ETM"
replace britcol = 0 if stateid=="KOS"
replace britcol = 0 if stateid=="MNC"
replace britcol = 0 if stateid=="MNG"
replace britcol = 1 if stateid=="NAU"
replace britcol = 0 if stateid=="PAL"
replace britcol = 0 if stateid=="RUS"
replace britcol = 1 if stateid=="SKN"
replace britcol = 0 if stateid=="TAW"
replace britcol = 1 if stateid=="TUV"
replace britcol = 1 if stateid=="UKG"
replace britcol = 0 if stateid=="WSM"

replace frencol = 0 if stateid=="ETM"
replace frencol = 0 if stateid=="KOS"
replace frencol = 0 if stateid=="MNC"
replace frencol = 0 if stateid=="MNG"
replace frencol = 0 if stateid=="NAU"
replace frencol = 0 if stateid=="PAL"
replace frencol = 0 if stateid=="RUS"
replace frencol = 0 if stateid=="SKN"
replace frencol = 0 if stateid=="TAW"
replace frencol = 0 if stateid=="TUV"
replace frencol = 0 if stateid=="WSM"
        
replace spanporc = 0 if stateid=="ETM"
replace spanporc = 0 if stateid=="KOS"
replace spanporc = 0 if stateid=="MNC"
replace spanporc = 0 if stateid=="MNG"
replace spanporc = 0 if stateid=="NAU"
replace spanporc = 0 if stateid=="PAL"
replace spanporc = 0 if stateid=="POR"
replace spanporc = 0 if stateid=="RUS"
replace spanporc = 0 if stateid=="SKN"
replace spanporc = 1 if stateid=="SPN"
replace spanporc = 0 if stateid=="TAW"
replace spanporc = 0 if stateid=="TUV"
replace spanporc = 0 if stateid=="WSM"

*identifying and replacing british legal heritage using T&U

list stateid country if leg_british==. & year==2020

replace leg_british = 0 if stateid=="AND"
replace leg_british = 0 if stateid=="BOS"
replace leg_british = 0 if stateid=="CRO"
replace leg_british = 0 if stateid=="CZR"
replace leg_british = 0 if stateid=="ERI"
replace leg_british = 0 if stateid=="ETM"
replace leg_british = 1 if stateid=="FSM"
replace leg_british = 0 if stateid=="KOS"
replace leg_british = 0 if stateid=="LIE"
replace leg_british = 0 if stateid=="MAC"
replace leg_british = 0 if stateid=="MNG"
replace leg_british = 1 if stateid=="MSI"
replace leg_british = 1 if stateid=="NAU"
replace leg_british = 1 if stateid=="PAL"
replace leg_british = 0 if stateid=="RUS"
replace leg_british = 1 if stateid=="SKN"
replace leg_british = 0 if stateid=="SLO"
replace leg_british = 0 if stateid=="SLV"
replace leg_british = 0 if stateid=="SNM"
replace leg_british = 0 if stateid=="TAW"
replace leg_british = 1 if stateid=="TUV"
replace leg_british = 1 if stateid=="WSM"
replace leg_british = 0 if stateid=="YEM"
replace leg_british = 0 if stateid=="MNC"

sort stateid year

********************Merge WDI (socioeconomic data)***************************
*Cutnote: remove folder root in final version
merge m:m stateid year using "ExtraDatasets/WDI_selects.dta"
*GDP, Remittance, Population, Refugee Data
*WDI is only up to 1960. Check _m==1 past this date
list country year stateid if _m==1 & year>1960
*The only missing case is Taiwain. 
*Let's see who else was added from WDI that doesn't match EVRR
list country if _m==2 & year==2020
*These are non-soverign territories.  Drop them
drop if _m==2
drop _m
*Destring and generate variables
replace GDP="" if GDP==".."
destring GDP, replace
gen lnGDP = ln(GDP)

replace WDIpop="" if WDIpop==".."
destring WDIpop, replace
gen lnpop = ln(WDIpop)

replace GDPpercap="" if GDPpercap==".."
destring GDPpercap, replace
gen lngdp_pc = ln(GDPpercap)

replace RemitPctGDP="" if RemitPctGDP==".."
destring RemitPctGDP, replace


sort stateid year


*********************Merge Polity (regime data)*********************
*Cutnote: remove folder root in final version
merge m:m stateid year using "ExtraDatasets/Polity5.dta"
list country year if _m==1
*_m==1 is microstates, pre-independence values, and after 2018
list country year if _m==1 & year==2020
list country year if _m==2 & year>1949 & year!=2020
*_m==2 is  East Germany, South Vietnam Yemen South(?)*
*Drop them for now
drop if _m==2 
drop _m
*Need to create a logged durable variable. Add 1 to equation to force the zero value.  
gen lndurable = ln(1 + durable)
*check to see which countries were missing from Polity
list stateid country year if lndurable==. & year==2017
*Following T&U, replace these as 0 values

replace lndurable = 0 if stateid=="AAB"
replace lndurable = 0 if stateid=="AND"
replace lndurable = 0 if stateid=="BAR"
replace lndurable = 0 if stateid=="BHM"
replace lndurable = 0 if stateid=="BLZ"
replace lndurable = 0 if stateid=="BRU"
replace lndurable = 0 if stateid=="DMA"
replace lndurable = 0 if stateid=="FSM"
replace lndurable = 0 if stateid=="GRN"
replace lndurable = 0 if stateid=="ICE"
replace lndurable = 0 if stateid=="KBI"
replace lndurable = 0 if stateid=="LIE"
replace lndurable = 0 if stateid=="MAD"
replace lndurable = 0 if stateid=="MLT"
replace lndurable = 0 if stateid=="MNC"
replace lndurable = 0 if stateid=="MSI"
replace lndurable = 0 if stateid=="NAU"
replace lndurable = 0 if stateid=="PAL"
replace lndurable = 0 if stateid=="SEY"
replace lndurable = 0 if stateid=="SKN"
replace lndurable = 0 if stateid=="SLU"
replace lndurable = 0 if stateid=="SNM"
replace lndurable = 0 if stateid=="STP"
replace lndurable = 0 if stateid=="SVG"
replace lndurable = 0 if stateid=="TON"
replace lndurable = 0 if stateid=="TUV"
replace lndurable = 0 if stateid=="VAN"
replace lndurable = 0 if stateid=="WSM"

*And let's tag these cases for future reference

gen gap_polity = 0

replace gap_polity = 1 if stateid=="AAB"
replace gap_polity = 1 if stateid=="AND"
replace gap_polity = 1 if stateid=="BAR"
replace gap_polity = 1 if stateid=="BHM"
replace gap_polity = 1 if stateid=="BLZ"
replace gap_polity = 1 if stateid=="BRU"
replace gap_polity = 1 if stateid=="DMA"
replace gap_polity = 1 if stateid=="FSM"
replace gap_polity = 1 if stateid=="GRN"
replace gap_polity = 1 if stateid=="ICE"
replace gap_polity = 1 if stateid=="KBI"
replace gap_polity = 1 if stateid=="LIE"
replace gap_polity = 1 if stateid=="MAD"
replace gap_polity = 1 if stateid=="MLT"
replace gap_polity = 1 if stateid=="MNC"
replace gap_polity = 1 if stateid=="MSI"
replace gap_polity = 1 if stateid=="NAU"
replace gap_polity = 1 if stateid=="PAL"
replace gap_polity = 1 if stateid=="SEY"
replace gap_polity = 1 if stateid=="SKN"
replace gap_polity = 1 if stateid=="SLU"
replace gap_polity = 1 if stateid=="SNM"
replace gap_polity = 1 if stateid=="STP"
replace gap_polity = 1 if stateid=="SVG"
replace gap_polity = 1 if stateid=="TON"
replace gap_polity = 1 if stateid=="TUV"
replace gap_polity = 1 if stateid=="VAN"
replace gap_polity = 1 if stateid=="WSM"

sort stateid year

**There are some double observations**
list country stateid year polity2v5 durable if year==year[_n-1]
**Used Polity excel file to identify correct value**
*Vietnam is just a double value
drop if stateid=="DRV" & year==1976 & year[_n+1]==1977
*Ethiopia is a Polity problem. Went with the row that fits previous data
drop if stateid=="ETH" & year==1993 & year[_n+1]==1994
*The is an amalgamation issue. Drop the West German value, keep Germany
drop if stateid=="GFR" & year==1990 & durable==41
*More amalgamation issues with Yugoslavia
drop if stateid=="SER" & year==1991 & durable==37
drop if stateid=="SER" & year==2006 & durable==5
*This is a weird amalgamation issue. Kept the "Sudan-North" value
drop if stateid=="SUD" & year==2011 & polity2v5==-2
*Amalgamation. Kept the newest value
drop if stateid=="YEM" & year==1990 & durable==24
*Double check
list country stateid year polity2v5 durable if year==year[_n-1]
*Should be empty, which means good to go

sort stateid year


**********************Merge NELDA (elections)***************
*Cutnote: remove folder root in final version
merge m:m stateid year using "ExtraDatasets/nelda.dta"
*_m==1 are all the years that didn't have elections
list country year if _m==2 & year>1949
*A collection of former states and autonomous regions
drop if _m==2
gen elecyear=0
replace elecyear=1 if _m==3
drop _m

sort stateid year

*NELDA has more than 1 observation in a year, so we end up with double entries
list country year if year==year[_n-1]
*Since the key variable - elecyear - is 1 for all the double entries, delete 1
drop if year==year[_n-1]

sort stateid year


********************Add labels to key variables***********************

*Adding former communist dummy, copying from T&U
*The variable is called "ceeurope"
*T&U Coding Q: Was country part of the USSR's European sphere of influence?

gen fmrsoviet = 0
replace fmrsoviet = 1 if stateid=="ALB"
replace fmrsoviet = 1 if stateid=="ARM"
replace fmrsoviet = 1 if stateid=="AZE"
replace fmrsoviet = 1 if stateid=="BLR"
replace fmrsoviet = 1 if stateid=="BOS"
replace fmrsoviet = 1 if stateid=="CRO"
replace fmrsoviet = 1 if stateid=="CZR"
replace fmrsoviet = 1 if stateid=="EST"
replace fmrsoviet = 1 if stateid=="GRG"
replace fmrsoviet = 1 if stateid=="HUN"
replace fmrsoviet = 1 if stateid=="KOS"
replace fmrsoviet = 1 if stateid=="KYR"
replace fmrsoviet = 1 if stateid=="LAT"
replace fmrsoviet = 1 if stateid=="LIT"
replace fmrsoviet = 1 if stateid=="MAC"
replace fmrsoviet = 1 if stateid=="MLD"
replace fmrsoviet = 1 if stateid=="MNG"
replace fmrsoviet = 1 if stateid=="POL"
replace fmrsoviet = 1 if stateid=="RUM"
replace fmrsoviet = 1 if stateid=="RUS"
replace fmrsoviet = 1 if stateid=="SER"
replace fmrsoviet = 1 if stateid=="SLO"
replace fmrsoviet = 1 if stateid=="SLV"
replace fmrsoviet = 1 if stateid=="TAJ"
replace fmrsoviet = 1 if stateid=="TKM"
replace fmrsoviet = 1 if stateid=="UKR"
replace fmrsoviet = 1 if stateid=="UZB"


*Temporary change until cap construction extended to 2020
*label variable cap_delta_evrr_dejure  "Recent nearby franchise adoption"
*label variable cap_delta_evrr_defacto  "Recent nearby franchise implementation"
label variable elecyear  "Election year"
label variable britcol  "British empire"
label variable frencol  "French empire"
label variable spanporc  "Spanish empire"
label variable leg_british  "English legal heritage"
label variable lndurable  "ln(years since regime change)"
label variable lngdp_pc  "ln(per-capita GDP)"
label variable lnpop  "ln(population)"
label variable fmrsoviet  "Central or Eastern Europe"


save "diffusion.dta", replace




****************Prepping T&U data for merge*********************

clear

use "ExtraDatasets/diaspora_enfranchisement_data.dta", replace

do "z_stateid_crosswalk.do"

list country year if stateid=="xxx"
*** It's small countries not included in EVRR
*** Except for Cote D'Ivore, which seems to be a chachrter mix-up in transfer
*** Let's fix it

replace stateid ="CDI" if cono==51 


*Tag the T&U variables for merge with main dataset

rename country TU_country
rename newextvote TU_newextvote
rename idea2013 TU_idea2013
rename pop TU_pop
rename gdpdoll TU_gdpdoll
rename rgdpch TU_rgdpch
rename econcat TU_econcat
rename gdprate TU_gdprate
rename remit TU_remit
rename lngdp TU_lngdp
rename lnpop TU_lnpop
rename electyear TU_electyear
rename referendum TU_referendum
rename execrlc TU_execrlc
rename rlc TU_rlc
rename gov1rlc TU_gov1rlc
rename kaufcorr TU_kaufcorr
rename ti_cpi TU_ti_cpi
rename ceeurope TU_ceeurope
rename lndur TU_lndur
rename transit TU_transit
rename politydur TU_politydur
rename cap6lag TU_cap6lag
rename queenlag TU_queenlag
rename k6partnr TU_k6partnr
rename exp6delco TU_exp6delco
rename k6lag TU_k6lag
rename remitrate TU_remitrate
rename cono TU_cono
rename debtrate TU_debtrate
rename debtdoll TU_debtdoll
rename lnwbdebt TU_lnwbdebt
rename k06delta TU_k06delta
rename qdelta TU_qdelta
rename cap6delta TU_cap6delta
rename par6delta TU_par6delta
rename exp6delta TU_exp6delta
rename k6delta TU_k6delta
rename curracct TU_curracct
rename currdec TU_currdec
rename govdebtrr TU_govdebtrr
rename extdebtrr TU_extdebtrr
rename lngovdrr TU_lngovdrr
rename lnextdrr TU_lnextdrr
rename govdebtimf TU_govdebtimf
rename govdebtwb TU_govdebtwb
rename govdebtoecd TU_govdebtoecd
rename extdebt TU_extdebt
rename lngovdimf TU_lngovdimf
rename lngovdwb TU_lngovdwb
rename lngovdoecd TU_lngovdoecd
rename govdebt TU_govdebt
rename politydem TU_politydem
rename newdem TU_newdem
rename newdem2 TU_newdem2
rename legengl TU_legengl
rename legsoc TU_legsoc
rename legfren TU_legfren
rename leggerm TU_leggerm
rename legscan TU_legscan
rename colbrit TU_colbrit
rename colfren TU_colfren
rename colspan TU_colspan
rename trenchfilt TU_trenchfilt

label variable TU_electyear  "Election year"
label variable TU_referendum  "Referendum year"
label variable TU_colb  "British empire"
label variable TU_colf  "French empire"
label variable TU_cols  "Spanish empire"
label variable TU_legengl  "English legal heritage"
label variable TU_lndur  "ln(years since regime change)"
label variable TU_lngdp  "ln(per-capita GDP)"
label variable TU_lnpop  "ln(population)"
label variable TU_ceeurope  "Central or Eastern Europe"

*And drop the variables generated by the hazard model
drop _st
drop _d
drop _t
drop _t0


sort stateid year

merge stateid year using "diffusion.dta"







***Repoduces Appendix 3.5, Table 3***

egen statenum = group(stateid)

sort statenum year

stset year, failure(TU_newextvote==1) id(statenum)

stcox cap_delta_TUidea TU_electyear TU_referendum, r
stcox cap_delta_TUidea TU_electyear TU_referendum TU_colb TU_colf TU_cols TU_legengl, r
stcox cap_delta_TUidea TU_electyear TU_referendum TU_colb TU_colf TU_cols TU_legengl TU_lngdp TU_lnpop TU_lndur, r
stcox cap_delta_TUidea TU_electyear TU_referendum TU_colb TU_colf TU_cols TU_legengl TU_lngdp TU_lnpop TU_lndur TU_ceeurope, r

drop _st - _t0


***This is Appendix 3.6 Table 4***

sort statenum year

stset year, failure(DVAdoptYr==1) id(statenum)

stcox cap_delta_evrr1 elecyear, r
stcox cap_delta_evrr1 elecyear britcol frencol spanporc leg_british, r
stcox cap_delta_evrr1 elecyear britcol frencol spanporc leg_british lndurable lngdp_pc lnpop, r
stcox cap_delta_evrr1 elecyear britcol frencol spanporc leg_british lndurable lngdp_pc lnpop fmrsoviet, r

drop _st - _t0

***This is Appendix 3.6 Table 5***

sort statenum year

stset year, failure(DVImpYr==1) id(statenum)

stcox cap_delta_evrr2, r
stcox cap_delta_evrr2 britcol frencol spanporc leg_british, r
stcox cap_delta_evrr2 britcol frencol spanporc leg_british lndurable lngdp_pc lnpop, r
stcox cap_delta_evrr2 britcol frencol spanporc leg_british lndurable lngdp_pc lnpop fmrsoviet, r

drop _st - _t0

***Reproduces Appendix 3.7, Tables 6 + 7***

sort statenum year

stset year, failure(DVAdoptYr==1) id(statenum)

stcox cap_delta_evrr1 TU_electyear TU_referendum, r
stcox cap_delta_evrr1 TU_electyear TU_referendum TU_colb TU_colf TU_cols TU_legengl, r
stcox cap_delta_evrr1 TU_electyear TU_referendum TU_colb TU_colf TU_cols TU_legengl TU_lngdp TU_lnpop TU_lndur, r
stcox cap_delta_evrr1 TU_electyear TU_referendum TU_colb TU_colf TU_cols TU_legengl TU_lngdp TU_lnpop TU_lndur TU_ceeurope, r

drop _st - _t0


sort statenum year

stset year, failure(DVImpYr==1) id(statenum)

stcox cap_delta_evrr2 TU_electyear TU_referendum, r
stcox cap_delta_evrr2 TU_electyear TU_referendum TU_colb TU_colf TU_cols TU_legengl, r
stcox cap_delta_evrr2 TU_electyear TU_referendum TU_colb TU_colf TU_cols TU_legengl TU_lngdp TU_lnpop TU_lndur, r
stcox cap_delta_evrr2 TU_electyear TU_referendum TU_colb TU_colf TU_cols TU_legengl TU_lngdp TU_lnpop TU_lndur TU_ceeurope, r

drop _st - _t0



***Appendix 3.8 - Table 8***

*Generate interaction dummies
gen cap_evrr1Xgdp_pc = cap_delta_evrr1*lngdp_pc
gen cap_evrr1Xpop = cap_delta_evrr1*lnpop
gen cap_evrr2Xgdp_pc = cap_delta_evrr2*lngdp_pc
gen cap_evrr2Xpop = cap_delta_evrr2*lnpop

label variable cap_evrr1Xgdp_pc  "Recent nearby franchise adoption X GDP"
label variable cap_evrr1Xpop  "Recent nearby franchise adoption X Pop"
label variable cap_evrr2Xgdp_pc  "Recent nearby franchise implementation X GDP"
label variable cap_evrr2Xpop  "Recent nearby franchise implementation X Pop"

sort statenum year

stset year, failure(DVAdoptYr==1) id(statenum)

stcox cap_delta_evrr1 elecyear britcol frencol spanporc leg_british lndurable lngdp_pc lnpop, r
stcox cap_delta_evrr1 elecyear britcol frencol spanporc leg_british lndurable lngdp_pc lnpop cap_evrr1Xpop, r
stcox cap_delta_evrr1 elecyear britcol frencol spanporc leg_british lndurable lngdp_pc lnpop cap_evrr1Xgdp_pc, r
stcox cap_delta_evrr1 elecyear britcol frencol spanporc leg_british lndurable lngdp_pc lnpop cap_evrr1Xpop cap_evrr1Xgdp_pc, r

drop _st - _t0

sort statenum year

***Appendix 3.8 - Table 9***

stset year, failure(DVImpYr==1) id(statenum)

stcox cap_delta_evrr2 britcol frencol spanporc leg_british lndurable lngdp_pc lnpop, r
stcox cap_delta_evrr2 britcol frencol spanporc leg_british lndurable lngdp_pc lnpop cap_evrr2Xpop, r
stcox cap_delta_evrr2 britcol frencol spanporc leg_british lndurable lngdp_pc lnpop cap_evrr2Xgdp_pc, r
stcox cap_delta_evrr2 britcol frencol spanporc leg_british lndurable lngdp_pc lnpop cap_evrr2Xpop cap_evrr2Xgdp_pc, r

sort stateid year





***Generates Figure 5***

sort statenum year

stset year, failure(DVAdoptYr==1) id(statenum)
stcox cap_delta_evrr1 lngdp_pc britcol frencol spanporc leg_british lndurable lngdp_pc lnpop, r
margins, dydx(cap_delta_evrr1) atmeans predict(xb) saving(fig5_file1, replace) post
est store evrr_dejure_post

stset year, failure(DVImpYr==1) id(statenum)
stcox cap_delta_evrr2 britcol frencol spanporc leg_british lndurable lngdp_pc lnpop, r
margins, dydx(cap_delta_evrr2) atmeans predict(xb) saving(fig5_file2, replace) post
est store evrr_defacto_post

coefplot evrr_dejure_post evrr_defacto_post, vertical ylab(-2 -1 0 1 2 3) aspect(2) yline(0) xlab(0.82 "Adoption" 2.15 "Implementation") legend(off) xtitle("Baseline") scheme(s1mono)
graph export "Fig5.png", replace width(1280)



***Generates Figure 6***

stset year, failure(DVImpYr==1) id(statenum)
stcox i.cap_delta_evrr2##c.lnpop britcol frencol spanporc leg_british lndurable lngdp_pc lnpop, r
margins, dydx(cap_delta_evrr2) at(lnpop=(10(1)20)) atmeans predict(xb) post saving(fig6_file1, replace)
est store evrr_defactolnpoppost
coefplot evrr_defactolnpoppost, vertical ylabel(-2 -1 0 1 2 3) yline(0) ciopts(recast(rarea)) recast(line) xlab(2.5 "100K" 4.8 "1M" 7.1 "10M" 9.4 "100M") xtitle("Implementation Interacted With Population") scheme(s1mono)
graph export "Fig6.png", replace width(1280)



